﻿function w3_open() {
    document.getElementsByClassName("admin-main-menu")[0].style.width = "280px";
    document.getElementsByClassName("w3-overlay")[0].style.display = "block";
    document.getElementsByClassName("mp-staff-img")[0].style.width = "110px";
    document.getElementsByClassName("mp-staff-img")[0].style.height = "110px";
    $(".user-item").addClass("w3-center");
    document.getElementsByClassName("mp-open-menu-item")[0].style.display = "none";
    document.getElementsByClassName("mp-close-menu-item")[0].style.display = "block";
    document.getElementsByClassName("mp-user-name")[0].style.display = "block";
    var tit = document.getElementsByClassName("menu-tittle");
    for (var i = 0; i < tit.length; i++) {
        tit[i].style.display = "inline-block";
    }
    var dropsign = document.getElementsByClassName("drop-down-sign");
    for (var i = 0; i < dropsign.length; i++) {
        dropsign[i].style.display = "inline-block";
    }
    var colldropsign = document.getElementsByClassName("collapse-drop-down-sign");
    for (var i = 0; i < colldropsign.length; i++) {
        colldropsign[i].style.display = "none";
    }
    var modal = document.getElementsByClassName("w3-modal");
    for (var i = 0; i < modal.length; i++) {
        modal[i].style.display = "none";
    }
    var videotarget = document.getElementsByClassName("gal-video-target");
    for (var i = 0; i < videotarget.length; i++) {
        videotarget[i].src = "";
    }
}
function w3_close() {
    document.getElementsByClassName("admin-main-menu")[0].style.width = "58px";
    document.getElementsByClassName("w3-overlay")[0].style.display = "none";
    document.getElementsByClassName("mp-staff-img")[0].style.width = "40px";
    document.getElementsByClassName("mp-staff-img")[0].style.height = "40px";
    $(".user-item").removeClass("w3-center");
    document.getElementsByClassName("mp-open-menu-item")[0].style.display = "block";
    document.getElementsByClassName("mp-close-menu-item")[0].style.display = "none";
    document.getElementsByClassName("mp-user-name")[0].style.display = "none";
    var tit = document.getElementsByClassName("menu-tittle");
    for (var i = 0; i < tit.length; i++) {
        tit[i].style.display = "none";
    }
    var dropsign = document.getElementsByClassName("drop-down-sign");
    for (var i = 0; i < dropsign.length; i++) {
        dropsign[i].style.display = "none";
    }
    var colldropsign = document.getElementsByClassName("collapse-drop-down-sign");
    for (var i = 0; i < colldropsign.length; i++) {
        colldropsign[i].style.display = "inline-block";
    }
    if ($(".admin-dropdown-menu").hasClass("dropped")) {
        $(".dropped").children().children(".drop-down-sign").removeClass("cong-quay");
        $(".dropped").children().children(".collapse-drop-down-sign").removeClass("muiten-quay");
        $(".dropped").children(".admin-sub-menu").animate({ height: "toggle" }, "fast");
        $(".dropped").removeClass("dropped");
    }
}
function access_deny() {
    document.getElementById("admin_error_content").innerHTML = "Bạn không được quyền truy cập vào mục này!";
    document.getElementById("admin-error-modal").style.display = "block";
    setTimeout('$("#admin-error-modal").fadeOut(),w3_close()', 3000);
}
function notification_load() {
    var xhttp;
    xhttp = new XMLHttpRequest();
    xhttp.onreadystatechange = function () {
        if (this.readyState == 4 && this.status == 200) {
            document.getElementById("admin_notification_count").innerHTML = this.responseText;
            if ($("#admin_notification_count>a").text().trim() != "0") {
                $("#mt_notification_count").text($("#admin_notification_count>a").text().trim());
                $("#mt_notification_count").show();
            }
            else
                $("#mt_notification_count").hide();
        }
    };
    xhttp.open("GET", "../Ajax/ASP/Notification/notification_count.aspx", true);
    xhttp.send();
}
$(document).ready(function () {
    $(".admin-menu").click(function () {
        $(".w3-overlay").fadeIn();
    });
    $(".admin-dropdown-menu").click(function () {
        if ($(this).hasClass("dropped")) {
            $(this).children().children(".drop-down-sign").removeClass("cong-quay");
            $(this).children().children(".collapse-drop-down-sign").removeClass("muiten-quay");
            $(this).children(".admin-sub-menu").animate({ height: "toggle" }, "fast");
            $(this).removeClass("dropped");
        }
        else if ($(".admin-dropdown-menu").hasClass("dropped")) {
            $(".dropped").children().children(".drop-down-sign").removeClass("cong-quay");
            $(".dropped").children().children(".collapse-drop-down-sign").removeClass("muiten-quay");
            $(".dropped").children(".admin-sub-menu").animate({ height: "toggle" }, "fast");
            $(".dropped").removeClass("dropped");
            $(this).addClass("dropped");
            $(this).children().children(".drop-down-sign").addClass("cong-quay");
            $(this).children().children(".collapse-drop-down-sign").addClass("muiten-quay");
            $(this).children(".admin-sub-menu").animate({ height: "toggle" }, "fast");
        }
        else {
            $(this).addClass("dropped");
            $(this).children().children(".drop-down-sign").addClass("cong-quay");
            $(this).children().children(".collapse-drop-down-sign").addClass("muiten-quay");
            $(this).children(".admin-sub-menu").animate({ height: "toggle" }, "fast");
        }
    });
    notification_load();
    setInterval(function () { notification_load() }, 5000);
});

$(document).ready(function () {
    var browserHeight = window.innerHeight; //lấy chiều cao khung trình duyệt trên các trình duyệt khác
    $('.admin-main-content').css({ "min-height": browserHeight });//gán min-height bằng chiều cao tính được (cho FF, Chrome,...)

});